#ifndef GPA_DECLARATIONS
#define GPA_DECLARATIONS

#include <ctype.h>
#include <sstream>
using namespace std;


struct GpaRecord
{
  string courseName;
  char letterGrade[2];
  int creditHours;
};

float gradeToFloat(char x[2])
{
  float result=0.0;
  x[0]=toupper(x[0]);

  switch(x[0])
  {
    case 'A':
      result=4.0;
      break;
    case 'B':
      result=3.0;
      break;
    case 'C':
      result=2.0;
      break;
    case 'D':
      result=1.0;
      break;
    default:
      result=0.0;
  };

  switch(x[1])
  {
    case '+':
      result+=0.30; /*result+=1.0/3.0*/
      break;
    case '-':
      result-=0.30; /*result-=1.0/3.0*/
  };

  if(result > 4.0)
    result=4.0;
  if(result < 0.0)
    result=0.0;
    
  return result;
}

string getGpa(float x)
{
  ostringstream conversionStream;
  
  x+=0.005; /*This assumes 3 significant digits*/

  conversionStream << setprecision(3) << fixed << x;
  return conversionStream.str();  
}



#endif
